package com.ruijixiang.leetcode.everyday.leetcode2024.leetcode202409;

public class leetcode20240921 {
    public int edgeScore(int[] edges) {
        long[] sum=new long[edges.length];
        for(int i=0;i<edges.length;i++){
            sum[edges[i]]+=i;
        }
        long mx=sum[0];
        int ans=0;
        for(int i=1;i<edges.length;i++){
            if(sum[i]>mx){
                mx=sum[i];
                ans=i;
            }
        }
        return ans;
    }
}
